home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1996 #3 / Amiga Plus CD - 1996 - No. 3.iso / demo-versionen / databaseprofessional_v3.0 / picbase / picturebase.rexx < prev    next >
OS/2 REXX Batch file  |  1995-12-29  |  9KB  |  353 lines

  1. /* PictureBase, Bildverwaltung mit DataBase Professional, 10.08.95, Jörg Richter */
  2.  
  3. OPTIONS RESULTS
  4.  
  5. RenderScreen = "Amiga 167936 640 256 256"
  6.                    /* dispID  x   y  colors */
  7. DIAsize      = 120  /* Vorschaugröße */
  8. TempDefaults = "T:ADPro.defaults"
  9. NL           = D2C(10)
  10. device       = "CON:0/0/640/200/Information/WAIT/CLOSE/SCREENDataBase"
  11.  
  12. ADDRESS DataBase DBTOFRONT
  13.  
  14. ADDRESS COMMAND
  15. 'C:Requestfile > ENV:picpath DRAWERSONLY TITLE="Quellpfad der Bilder" NOICONS PUBSCREEN DataBase'
  16. IF RC = 0 THEN DO
  17.   'C:Requestfile > ENV:thumb DRAWER DBPRO:PicBase DRAWERSONLY TITLE="Pfad für Vorschaubilder" NOICONS PUBSCREEN DataBase'
  18.   IF RC = 0 THEN DO
  19.     'Echo > ENV:thumbpath $thumb'
  20.     'Echo > ENV:source $picpath'
  21.     ADDRESS DataBase RequestText "Datei-Muster ~(#?.info)"
  22.     IF result = "" THEN
  23.       'Echo > ENV:patt ~(#?.info)'
  24.     ELSE
  25.       'Echo > ENV:patt ' || result
  26.     ADDRESS DataBase Message "Erzeuge Verzeichnisstruktur für Vorschaubilder ..."
  27.     'List > T:script $picpath dirs all lformat="$source %p%n $thumbpath"'
  28.     CALL MakeDirs
  29.     ADDRESS DataBase Message "Scanne Quellpfad der Bilder ..."
  30.     'List > T:script $picpath P=$patt files all lformat="$thumbpath $source %p%n %l"'
  31.     ADDRESS DataBase
  32.     Request "_Ja|_Nein|_Abbruch" "Haben Sie ADPro installiert ?" || NL || NL || "(Ansonsten wird das PBMplus Paket verwendet.)"
  33.     adpro = RC
  34.     IF adpro = 0 THEN EXIT
  35.     IF adpro = 1 THEN DO
  36.       Request "_IFF|_GIF|_Abbruch" "*** ADPro starten ***" || NL || NL || "Format für die Vorschaubilder ?"
  37.       IF RC > 0 THEN DO
  38.         IF RC = 1 THEN
  39.           saveop = "IFF"
  40.         ELSE
  41.           saveop = "GIF"
  42.         CALL PicBase
  43.       END
  44.       END /* DO */
  45.     ELSE DO
  46.       Request "_Farben|_Graustufen|_Abbruch" "Vorschaubilder in 256 Farben oder 16 Graustufen umrechnen ?"
  47.       colop = RC
  48.       IF colop > 0 THEN DO
  49.         colop = RC
  50.         CALL PicBasePBM
  51.         END
  52.       END /* DO */
  53.     ADDRESS DataBase DBTOFRONT
  54.     ADDRESS COMMAND
  55.     'C:Delete > NIL: T:script'
  56.   END
  57. END
  58.  
  59. EXIT
  60.  
  61.  
  62. MakeDirs:
  63.  
  64. ok = Open(file,'ENV:thumbpath',R)
  65. dest = ReadLn(file)
  66. 'C:MakeDir > NIL: ' || LEFT(dest,Length(dest)-1)
  67. ok = Close(file)
  68.  
  69. ok = Open(file,"T:script",R)
  70. IF ok THEN DO
  71.   weiter = 0
  72.   DO WHILE weiter = 0
  73.     str = ReadLn(file)
  74.     IF Length(str) > 0 THEN DO
  75.       PARSE VAR str source dir dest .
  76.       dir = DelStr(dir,1,Length(source))
  77.       'C:MakeDir > NIL: ' dest || dir
  78.     END
  79.     weiter = EOF(file)
  80.   END
  81.   ok = Close(file)
  82. END
  83. RETURN
  84.  
  85.  
  86. PicBase:
  87.  
  88. weiter = 0
  89. DO WHILE weiter = 0
  90.   weiter = Show('P','ADPro')
  91.   IF weiter = 0 THEN DO
  92.     ADDRESS DataBase
  93.     Request "_Gestartet|_Abbruch" "Bitte ADPro starten ..."
  94.     IF RC = 0 THEN EXIT
  95.     ADDRESS
  96.   END
  97. END
  98.  
  99. ok = Open(file,"T:script",R)
  100. IF ok THEN DO
  101.   ADDRESS "ADPro" SAVE_DEFAULTS TempDefaults
  102.   ok = Open(out,device,W)
  103.   cnt = WriteLn(out,"Start : " || TIME())
  104.   reset = TIME(r)
  105.   weiter = 0
  106.   DO WHILE weiter = 0
  107.     str = ReadLn(file)
  108.     IF Length(str) > 0 THEN
  109.       CALL CreateThumb
  110.     weiter = EOF(file)
  111.   END
  112.   ok = Close(file)
  113.   ADDRESS "ADPro" LOAD_DEFAULTS TempDefaults
  114.   cnt = WriteLn(out,"Finish: " || TIME())
  115.   cnt = WriteLn(out,D2C(10) || "Convertion time (s): " || TIME(e))
  116.   ok = Close(out)
  117. END
  118. RETURN
  119.  
  120.  
  121. CreateThumb:
  122.  
  123. PARSE VAR str path source bild length .
  124. /*
  125.    path   = Pfad für das erzeugte Thumbnail
  126.    source = Quellpfad der Bilder
  127.    bild   = Pfad und Name des eigentlichenen Bildes
  128.    length = Dateilänge des Bildes
  129. */
  130.  
  131. IF RIGHT(path,1) ~= "/" THEN DO
  132.   IF RIGHT(path,1) ~= ":" THEN
  133.     path = path || "/"
  134. END
  135.  
  136. path = path || DelStr(bild,1,Length(source))
  137.  
  138. pos = MAX(LastPos("/",bild),LastPos(":",bild))+1
  139. bildname = SubStr(bild,pos,Length(bild)-pos+1)    /* Bildname ermitteln */
  140. pos = LastPos(".",bildname)
  141. IF pos > 0 THEN
  142.   bildname = LEFT(bildname,pos) || saveop
  143.  
  144. path = SubStr(path,1,Length(path)-Length(bildname))
  145.  
  146. IF Exists(path || bildname) = 1 THEN DO /* Falls Thumbnail schon existiert */
  147.   cnt = WriteLn(out,"Skipping: " || bild || " exists")
  148.   RETURN                               /* weiter mit nächsten Bild        */
  149. END
  150.  
  151. ADDRESS DataBase Message "Bearbeite " || bild || " ..."
  152.  
  153. ADDRESS "ADPro"
  154.  
  155. PSTATUS "LOCKED"
  156. DITHER 1
  157. IF Compare(RIGHT(bild,4),".PCD") = 0 THEN DO
  158.   ADDRESS COMMAND
  159.   'DBPRO:PicBase/PBMbin/hpcdtoppm > JPEGTMP:t.ppm -2 ' || bild
  160.   IF RC ~= 0 THEN DO
  161.     cnt = WriteLn(out,"Loading error: " || bild)
  162.     RETURN
  163.   END
  164.   ADDRESS "ADPro"
  165.   LOADER "PNM" "JPEGTMP:t.ppm"
  166.   END
  167. ELSE DO
  168.   pcd = 0
  169.   LOADER "UNIVERSAL" bild
  170.   IF RC ~= 0 THEN DO
  171.     cnt = WriteLn(out,"Loading error: " || bild)
  172.     RETURN
  173.   END
  174. END
  175. XSIZE
  176. width = ADPRO_RESULT
  177. YSIZE
  178. height = ADPRO_RESULT
  179. IF width > height THEN DO
  180.   yy = (height/width) * DIAsize
  181.   xx = DIAsize
  182.   END
  183. ELSE DO
  184.   xx = (width/height) * DIAsize
  185.   yy = DIAsize
  186.   END
  187. ABS_SCALE xx yy
  188. SET_RENDER_MODE RenderScreen
  189. EXECUTE
  190. SAVER saveop path || bildname "IMAGE"
  191. IF RC ~= 0 THEN DO
  192.   cnt = WriteLn(out,"Saving error : " || path || bildname)
  193.   RETURN
  194. END
  195.  
  196. ADDRESS DataBase
  197.  
  198. Add
  199. PutData $F1 bild
  200. PutData $F2 length
  201. PutData $F3 width || "x" || height
  202. IF Compare(LEFT(path,6),"DBPRO:") = 0 THEN path = DelStr(path,1,6)
  203. PutData $F4 path || bildname
  204.  
  205. RETURN
  206.  
  207. /* PBM Script */
  208.  
  209. PicBasePBM:
  210.  
  211. ok = Open(sfile,"T:script",R)
  212. IF ok THEN DO
  213.   ok = Open(out,device,W)
  214.   cnt = WriteLn(out,"Start : " || TIME())
  215.   reset = TIME(r)
  216.   weiter = 0
  217.   DO WHILE weiter = 0
  218.     str = ReadLn(sfile)
  219.     IF Length(str) > 0 THEN
  220.       CALL CreateThumbPBM
  221.     weiter = EOF(sfile)
  222.   END
  223.   ok = Close(sfile)
  224.   cnt = WriteLn(out,"Finish: " || TIME())
  225.   cnt = WriteLn(out,D2C(10) || "Convertion time (s): " || TIME(e))
  226.   ok = Close(out)
  227. END
  228. RETURN
  229.  
  230.  
  231. CreateThumbPBM:
  232.  
  233. PARSE VAR str path source bild length .
  234. /*
  235.    path   = Pfad für das erzeugte Thumbnail
  236.    source = Quellpfad der Bilder
  237.    bild   = Pfad und Name des eigentlichenen Bildes
  238.    length = Dateilänge des Bildes
  239. */
  240.  
  241. IF RIGHT(path,1) ~= "/" THEN DO
  242.   IF RIGHT(path,1) ~= ":" THEN
  243.     path = path || "/"
  244. END
  245.  
  246. path = path || DelStr(bild,1,Length(source))
  247.  
  248. pos = MAX(LastPos("/",bild),LastPos(":",bild))+1
  249. bildname = SubStr(bild,pos,Length(bild)-pos+1)    /* Bildname ermitteln */
  250. pos = LastPos(".",bildname)
  251. IF pos > 0 THEN
  252.   bildname = LEFT(bildname,pos) || "iff"
  253.  
  254. path = SubStr(path,1,Length(path)-Length(bildname))
  255.  
  256. IF Exists(path || bildname) = 1 THEN DO /* Falls Thumbnail schon existiert */
  257.   cnt = WriteLn(out,"Skipping: " || bild || " exists")
  258.   RETURN                               /* weiter mit nächsten Bild        */
  259. END
  260.  
  261. ADDRESS DataBase Message "Bearbeite " || bild || " ..."
  262.  
  263. ADDRESS COMMAND
  264.  
  265. 'DBPRO:PicBase/PBMbin/filetype ' || bild
  266. type = RC
  267.  
  268. IF type >= 6 THEN DO
  269.   IF Compare(RIGHT(bild,4),".PCD") = 0 THEN DO
  270.     'DBPRO:PicBase/PBMbin/hpcdtoppm > JPEGTMP:t.ppm -2 ' || bild
  271.     IF RC ~= 0 THEN DO
  272.       cnt = WriteLn(out,"Error loading PCD: " || bild)
  273.       RETURN
  274.       END
  275.     END
  276.   ELSE DO
  277.     cnt = WriteLn(out,"*** Error loading: " || bild)
  278.     cnt = WriteLn(out,"*** Supported formats: IFF, JPEG, GIF, PCX, BMP, TIFF, PhotoCD")
  279.     RETURN
  280.     END
  281.   END
  282. IF type = 0 THEN DO
  283.   'DBPRO:PicBase/PBMbin/ilbmtoppm > JPEGTMP:t.ppm ' || bild
  284.   IF RC ~= 0 THEN DO
  285.     cnt = WriteLn(out,"Error loading ILBM: " || bild)
  286.     RETURN
  287.     END
  288.   END
  289. IF type = 1 THEN DO
  290.   'DBPro:PicBase/PBMBIN/giftopnm > JPEGTMP:t.ppm ' || bild
  291.   IF RC ~= 0 THEN DO
  292.     cnt = WriteLn(out,"Error loading GIF: " || bild)
  293.     RETURN
  294.     END
  295.   END
  296. IF type = 2 THEN DO
  297.   'DBPRO:PicBase/PBMBIN/Djpeg > JPEGTMP:t.ppm ' || bild
  298.   IF RC ~= 0 THEN DO
  299.     cnt = WriteLn(out,"Error loading JPEG: " || bild)
  300.     RETURN
  301.     END
  302.   END
  303. IF type = 3 THEN DO
  304.   'DBPro:PicBase/PBMBIN/bmptoppm > JPEGTMP:t.ppm ' || bild
  305.   IF RC ~= 0 THEN DO
  306.     cnt = WriteLn(out,"Error loading BMP: " || bild)
  307.     RETURN
  308.     END
  309.   END
  310. IF type = 4 THEN DO
  311.   'DBPro:PicBase/PBMBIN/pcxtoppm > JPEGTMP:t.ppm ' || bild
  312.   IF RC ~= 0 THEN DO
  313.     cnt = WriteLn(out,"Error loading PCX: " || bild)
  314.     RETURN
  315.     END
  316.   END
  317. IF type = 5 THEN DO
  318.   'DBPro:PicBase/PBMBIN/tifftopnm > JPEGTMP:t.ppm ' || bild
  319.   IF RC ~= 0 THEN DO
  320.     cnt = WriteLn(out,"Error loading TIFF: " || bild)
  321.     RETURN
  322.     END
  323.   END
  324.  
  325. ADDRESS
  326. bool = Open(file,'JPEGTMP:t.ppm',R)
  327. str = ReadLn(file)
  328. str = ReadLn(file)
  329. width = WORD(str,1)
  330. height = WORD(str,2)
  331. bool = Close(file)
  332. ADDRESS COMMAND
  333.  
  334. 'DBPRO:PicBase/PBMBIN/pnmscale > JPEGTMP:s.ppm -xysize ' || DIAsize || ' ' || DIAsize || ' JPEGTMP:t.ppm'
  335. 'C:Delete > NIL: JPEGTMP:t.ppm'
  336. IF colop = 1 THEN
  337.   'DBPRO:PicBase/PBMBIN/ppmtoilbm > ' || path || bildname || ' -fs -mp 8 -map DBPRO:PicBase/PBMBIN/cmap.ppm JPEGTMP:s.ppm'
  338. ELSE
  339.   'DBPRO:PicBase/PBMBIN/ppmtoilbm > ' || path || bildname || ' -fs -mp 4 -map DBPRO:PicBase/PBMBIN/gmap.ppm JPEGTMP:s.ppm'
  340. 'C:Delete > NIL: JPEGTMP:s.ppm'
  341.  
  342. ADDRESS DataBase
  343.  
  344. Add
  345. PutData $F1 bild
  346. PutData $F2 length
  347. PutData $F3 width || "x" || height
  348. IF Compare(LEFT(path,6),"DBPRO:") = 0 THEN path = DelStr(path,1,6)
  349. PutData $F4 path || bildname
  350.  
  351. RETURN
  352.  
  353.